const { querySql, updateSql, insertSql, deleteSql } = require("../db");

function getClassSectionList(query) {
  const { sectionName } = query;
  return querySql(
    `select * from classSection_list where sectionName like '%${
      sectionName || ""
    }%' ORDER BY startTime ASC`
  );
}

function editClassSection(query) {
  query.updateTime = new Date();
  return updateSql(query, "classSection_list", `where id = ${query.id}`);
}

function createClassSection(query, cardId) {
  query.createTime = new Date();
  query.createId = cardId;
  return insertSql(query, "classSection_list");
}

function deleteClassSection(query) {
  return deleteSql("id", query.id, "classSection_list");
}

module.exports = {
  getClassSectionList,
  editClassSection,
  createClassSection,
  deleteClassSection,
};
